import unittest
def factors(num, fac=[]):
    if num <= 0:
        raise ValueError("Number must be positive.")
    if num == 1:
        return fac

    # 每次都从2开始查找因数
    for i in range(2, int(num**0.5) + 1):
        # 找到一个因数
        if num % i == 0:
            fac.append(i)
            # 对商继续分解，重复这个过程
            return factors(num // i, fac)
    
    # 不可分解了，自身也是个因数
    fac.append(num)
    return fac

class TestFactors(unittest.TestCase):
    def test_happy_path(self):
        self.assertEqual(factors(28), [2, 2, 7])
        self.assertEqual(factors(49), [7, 7])
        self.assertEqual(factors(100), [2, 2, 5, 5])

    def test_prime_number(self):
        self.assertEqual(factors(2), [2])
        self.assertEqual(factors(3), [3])
        self.assertEqual(factors(13), [13])

    def test_one(self):
        self.assertEqual(factors(1), [])

    def test_zero(self):
        with self.assertRaises(ValueError):
            factors(0)

    def test_negative_number(self):
        with self.assertRaises(ValueError):
            factors(-10)

    def test_large_number(self):
        self.assertEqual(factors(104729), [104729])



TestFactors().test_happy_path()

